-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(ci): validate imports from langchain
#1445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Mintlify preview ID generated: preview-mdrxyi-1763261349-1c07824 |
|
Mintlify preview ID generated: preview-mdrxyi-1763262755-71dcb2a |
|
Mintlify preview ID generated: preview-mdrxyi-1763263038-d1e9709 |
|
Mintlify preview ID generated: preview-mdrxyi-1763797132-816b00c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces an automated system to detect incorrect imports from langchain_core that should use re-exports from langchain. The implementation includes two Python scripts for analyzing and checking imports, comprehensive unit tests, and GitHub Actions workflows for continuous validation.
Key changes:
- Automated detection of
langchain_corere-exports available throughlangchain - PR validation workflow that comments on pull requests with import issues
- Scheduled workflow to keep import mappings up-to-date
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
tests/unit_tests/test_check_pr_imports.py |
Comprehensive unit tests for the PR import checker, covering diff parsing, import line validation, and mapping dictionary construction |
scripts/check_pr_imports.py |
Main script that analyzes PR diffs to identify incorrect langchain_core imports and suggests langchain alternatives |
scripts/check_import_mappings.py |
Script that introspects the latest langchain package to build a mapping of available re-exports from langchain_core |
scripts/__init__.py |
Package initializer for the scripts module |
.github/workflows/check-pr-imports.yml |
GitHub Actions workflow that runs on PRs to validate imports and comment with suggestions |
.github/workflows/check-import-mappings.yml |
Scheduled workflow that periodically updates import mappings and creates PRs with changes |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Mintlify preview ID generated: preview-mdrxyi-1763846662-d758e34 |
|
Mintlify preview ID generated: preview-mdrxyi-1763848469-6d4c979 |
|
Mintlify preview ID generated: preview-mdrxyi-1763849557-d2dee40 |
|
Mintlify preview ID generated: preview-mdrxyi-1763849963-0ef804a |
|
Mintlify preview ID generated: preview-mdrxyi-1763850090-c846f9d |
langchainlangchain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
| diff = """diff --git a/test.py b/test.py | ||
| index 1234567..abcdefg 100644 | ||
| --- a/test.py | ||
| +++ b/test.py |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff in the test case contains a line with 0 for the line number (line 226 shows +++ b/test.py followed by line 0). This doesn't match the actual diff format. While tests pass, the line numbering in the multiline string should represent realistic diff output for better test clarity and maintainability.
| diff = """diff --git a/file1.py b/file1.py | ||
| index 1234567..abcdefg 100644 | ||
| --- a/file1.py | ||
| +++ b/file1.py |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the previous test, the diff contains line number 0 (after +++ b/file1.py on line 249). While the tests work, this doesn't represent actual git diff output accurately, which could confuse future maintainers.
| diff --git a/file2.py b/file2.py | ||
| index 2345678..bcdefgh 100644 | ||
| --- a/file2.py | ||
| +++ b/file2.py |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff contains line number 0 (after +++ b/file2.py on line 256). Consider using realistic diff formatting in test cases to improve maintainability and clarity.
| diff = """diff --git a/test.py b/test.py | ||
| index 1234567..abcdefg 100644 | ||
| --- a/test.py | ||
| +++ b/test.py |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff contains line number 0 (after +++ b/test.py on line 283). While functional, realistic diff formatting would improve test documentation.
| diff = """diff --git a/test.py b/test.py | ||
| index 1234567..abcdefg 100644 | ||
| --- a/test.py | ||
| +++ b/test.py |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff contains line number 0 (after +++ b/test.py on line 300). Consider using realistic diff formatting for better test documentation.
Introduces an automated system to detecting and manage incorrect imports from
langchain_corein favor of using the re-exports fromlangchain.check-import-mappings.ymlworkflow to periodically analyze the latest version oflangchain_core, check for re-exports inlangchain(and generateimport_mappings.json), and automatically create PRs to update the mappings cache in this repo.check_import_mappings.pyto fetch latest package releases, introspectlangchainpublic__init__files, and generate a detailed mapping of re-exported members fromlangchain_core. Uses the previous localimport_mappings.jsoncheck-pr-imports.ymlworkflow to run on PRs, ensuring inbound contributions uselangchainimports when available, and comment on PRs with specific guidance if issues are found.check_pr_imports.pyto analyze PR diffs against the import mappings, detect incorrectlangchain_coreimports, and output suggested fixes for contributors.